home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7290 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: hal.COM!spike
  2. From: spike@hal.com (Spike White)
  3. Newsgroups: comp.lang.apl,comp.lang.asm.x86,comp.lang.c,comp.lang.c++,comp.os.ms-windows.programmer.networks
  4. Subject: Re: API Call to Acquire Ethernet Address
  5. Followup-To: comp.lang.apl,comp.lang.asm.x86,comp.lang.c,comp.lang.c++,comp.os.ms-windows.programmer.networks
  6. Date: 22 Feb 1996 15:35:12 GMT
  7. Organization: HAL Computer Systems, Inc.
  8. Message-ID: <4gi2fg$bcq@news.hal.com>
  9. References: <4f0bml$lvd@noc.tor.hookup.net> <4fnm1j$52@ns2.emirates.net.ae>
  10. NNTP-Posting-Host: zarathustra.hal.com
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Kannan (kannan@emirates.net.ae) wrote:
  14. : patrick@xiris.com (Patrick Whittle) wrote:
  15.  
  16. : >I need access to an API call that will return the
  17. : >ethernet address from a NIC.  Many programs and
  18. : >utilities I have used display the ethernet address 
  19. : >such as "arp -a" from the TCP/IP protocol siute.
  20.  
  21. : I too am interested in such a API call. please post it in this ng.
  22.  
  23. Good luck!  I had to write such a function on various UNIX system we
  24. ported to.  I was hoping for something analogous to 
  25. gethostname()/gethostaddr(), but no such luck.  Which is weird, because
  26. I see a ether_ntoa() which is analogous to inet_ntoa().
  27.  
  28. Altogether, it's about 400 lines of code since it must be done different
  29. ways on different platforms.  For platforms that support a DLPI interface
  30. to the ethernet h/w, it's reasonably portable.   But quite low-level --
  31. putting and getting STREAMS msgs.
  32.  
  33. My favorite way to do it is on Solaris.  On that OS (& apparently *only*
  34. on that OS), you can do a system("ifconfig -a") and parse the output.  It'll
  35. give the ethernet address of all interfaces.  It only does this as root,
  36. though.
  37.  
  38. If you find any simple _portable_ way to do it, I'd be extremely interested.
  39. And if you find an easy way to do it in Windows, I'd be interested in that
  40. also.
  41.  
  42. --
  43. Spike White          | spike@hal.com               | Biker Nerds
  44. HaL Software Systems | '87 BMW K75S, DoD #1347     |  From  HaL
  45. Austin, TX           |  http://www.halsoft.com/users/spike/index.html 
  46. Disclaimer:  HaL, want me to speak for you?  No, Dave... 
  47.